<template>
  <div>
    <p class="user">
      <el-row>
        <el-col>
          <div class="btn">
            <button class="el-icon-d-arrow-left" @click="change"></button>
            <button class="el-icon-refresh" @click="update"></button>
            <button class="el-icon-rank"></button>
            <button class="el-icon-edit"></button>
          </div>
          <div class="top-r">
            <times></times>
            欢迎您： {{ nowUser }}
            <button @click="out">退出登录</button>
          </div>
          <!-- {{time}} -->
        </el-col>
      </el-row>
    </p>
  </div>
</template>

<script>
import times from "./sec-router/timer";

export default {
  name: "VscodeInsidersTop",

  data() {
    return {
      nowUser: "", //当前登录用户名
      time: new Date(),
      customParseFormat: new Date(),
    };
  },
  components: {
    times,
  },
  mounted() {
    // this.out()
    this.getUserNanme();
  },

  methods: {
    getUserNanme() {
      this.nowUser = sessionStorage.getItem("userName"); //使用getIte得到缓存的名字 赋给nowUser
    },
    out() {
      console.log("111");
      window.sessionStorage.clear();
      this.$router.push("/");
    },
    change() {
      console.log("11");
      this.$emit("change");
    },
    update(){
      location.reload()
    }
  },
};
</script>

<style scoped>
.user {
  display: flex;
 
  float: left;
  height: 10px;
  padding: 2px;
  width: 78%;
  /* border: 1px red solid; */
}
.btn {
  display: inline-block;
  /* z-index: 1; */
  text-align: left;
  /* width: auto; */
  height: auto;
  /* background-color: aqua; */
}
.el-col-24 {
  width: 100%;
  text-align: right;
}
.top-r{
  /* background-color: aqua; */
  float: right;
  width: 700px;
}
</style>